YambCall = {
	name: "call",
	yamb: null,
	cantUndo: true,
	
	toPlayCollection: null,
	
	init: function() {
		this.yamb.table.find("td[game_column="+this.name+"]").addClass("toplay");
	},
	
	onRollDice: function() {
		if(this.yamb.throwCount>1) {
			this.yamb.table.find("td.field[game_column="+this.name+"]").each(function(){
				if(!$(this).hasClass("played")){
					$(this).addClass("toplay");
				}
			});
		}else{
			this.yamb.table.find("td.field[game_column="+this.name+"]").removeClass("toplay");
		}
	},
	
	play: function(td) {
		var value = this.yamb.getGameValue(td.attr("game_row"));
		if(value>0 && td.attr("game_row")=="straight") {
			td.html(value);
			td.addClass("played").removeClass("toplay").removeClass("called");
			return true;
		}else if(this.yamb.toPlay(td) && this.yamb.throwCount>=2) {
			if(this.isCalled(td)) {
				td.removeClass("called");
				this.toPlayCollection.addClass("toplay");
			}else{
				td.addClass("called");
				this.toPlayCollection = this.yamb.table.find("td.toplay");
				this.toPlayCollection.removeClass("toplay");
				td.addClass("toplay");
			}
		}else if(this.isCalled(td)) {
			var value = this.yamb.getGameValue(td.attr("game_row"));
			td.html(value);
			this.toPlayCollection.addClass("toplay");
			td.addClass("played").removeClass("called").removeClass("toplay");
			
			return true;
		}
		return false;
	},
	
	undo: function(td) {
		return false;
	},
	
	isCalled: function(td) {
		return td.hasClass("called") ? true : false;
	}
};